public class x的平方根 {
    //https://leetcode.cn/problems/jJ0w9p/description/
    //使用二分查找右边界查找
    public int mySqrt(int x) {
        long l = 0;
        long r = x;
        long ans = 0;
        while(l <= r){
            long m = (l + r) / 2;
            if(m * m <= x){
                ans = m;
                l = m + 1;
            }else{
                r = m - 1;
            }
        }
        return (int)ans;
    }
}
